home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / gdb-4.5 / dist / libiberty / strrchr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  1.2 KB  |  55 lines

  1. /* Portable version of strrchr().
  2.    Copyright (C) 1991 Free Software Foundation, Inc.
  3.  
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8.  
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. GNU General Public License for more details.
  13.  
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  17.  
  18. /*
  19.  
  20. NAME
  21.  
  22.     strrchr -- return pointer to last occurance of a character
  23.  
  24. SYNOPSIS
  25.  
  26.     char *strrchr (const char *s, int c)
  27.  
  28. DESCRIPTION
  29.  
  30.     Returns a pointer to the last occurance of character C in
  31.     string S, or a NULL pointer if no occurance is found.
  32.     
  33. BUGS
  34.  
  35.     Behavior when character is the null character is implementation
  36.     dependent.
  37.  
  38. */
  39.  
  40. #include <ansidecl.h>
  41.  
  42. char *
  43. strrchr (s, c)
  44.   register CONST char *s;
  45.   int c;
  46. {
  47.   char *rtnval = 0;
  48.  
  49.   do {
  50.     if (*s == c)
  51.       rtnval = s;
  52.   } while (*s++);
  53.   return (rtnval);
  54. }
  55.